package com.general.log4jConfig;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.log4j.PropertyConfigurator;
import org.springframework.context.ApplicationContext;

public class Log4jConfigServlet extends HttpServlet {
	 public static ApplicationContext ctx;
	public void init(ServletConfig config) throws ServletException {
		String prefix = config.getServletContext().getRealPath("/");
		prefix=prefix.substring(0,prefix.length()-1);
		String file = config.getInitParameter("log4j-init-file");
		if (file != null) {
			PropertyConfigurator.configure(prefix + file);
		}
	}
}